package com.webmarmun;

import com.mysql.jdbc.ResultSetMetaData;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import java.util.Iterator;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.table.TableModel;
import org.jdesktop.beansbinding.*;
import javax.persistence.*;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.Size2DSyntax;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.MediaSize;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.RowFilter;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;

public class FirstFrame extends javax.swing.JFrame {

    private String sveZajedno;
    private String str_date;
    public static String SU;
    public static String DATUM;
    public static String POROTNIK;
    public static String SUDIJA;
    public static String MESTO;
    public static Float RADNISAT;
    public static int BROJSATI;
    public static Float PREVOZ;
    public static Float PAUSALNO;
    public static Float UKUPNO;
    public static String NAPOMENA;
   // private final TableRowSorter<MyTableModel> sorter;

    
    public FirstFrame() {

        initComponents();
        String serverName = "localhost";
     String mydatabase = "porotnici";
     String url2 = "jdbc:mysql://" + serverName + "/" + mydatabase + "?useUnicode=true&characterEncoding=utf8";
     String username = "root";
     String password = "";
        Vector columnNames = new Vector();
        Vector data = new Vector();

//        DefaultTableModel m = new DefaultTableModel();
//        float rs;
//        float prev;
//        float pau;
//        int su;
//        String datum2;
//        String imePorotnika;
//        int BrojSati;
         try {

            java.sql.Connection connection = null;
            connection = DriverManager.getConnection(url2, username, password);

            java.sql.PreparedStatement t = connection.prepareStatement("SELECT * from evidencija");
            ResultSet trs = null;
            trs = t.executeQuery();
            java.sql.ResultSetMetaData md = trs.getMetaData();
            int columns = md.getColumnCount();
            //  Get column names

            for (int i = 1; i <= columns; i++)
            {
                columnNames.addElement( md.getColumnName(i) );
               
            }
            while (trs.next()) {
                Vector row = new Vector(columns);

                for (int i = 1; i <= columns; i++)
                {
                    row.addElement( trs.getObject(i) );
                    
                }

                data.addElement( row );
//                su = trs.getInt("id");
//                datum2 = trs.getString("datum");
//                imePorotnika = trs.getString("datum");
//                BrojSati = trs.getInt("broj_sati");
//                rs = trs.getFloat("po_satu");
//                prev = trs.getFloat("prevoz");
//                pau = trs.getFloat("pausalno");
             }

            trs.close();
            connection.close();

            JTable table = new JTable(data, columnNames)
        {
                @Override
            public Class getColumnClass(int column)
            {
                for (int row = 0; row < getRowCount(); row++)
                {
                    Object o = getValueAt(row, column);

                    if (o != null)
                    {
                        return o.getClass();
                    }
                }

                return Object.class;
            }
        };
       jScrollPane1.add(table);
       table.setVisible(true);
         


            }catch(SQLException e){
               System.out.println(e.toString());
            }
         //showTable();
        filterText.addMouseListener(
                new MouseListener(){
           

            public void mouseClicked(MouseEvent e) {
                 filterText.setText("");
            }

            public void mousePressed(MouseEvent e) {
                 filterText.setText("");
            }

            public void mouseReleased(MouseEvent e) {
                 filterText.setText("");
            }

            public void mouseEntered(MouseEvent e) {
                filterText.setText("");
            }

            public void mouseExited(MouseEvent e) {
               
            }


        }

                );


        //MyTableModel model = new MyTableModel();
       // sorter = new TableRowSorter<MyTableModel>(model);

       // jTable1.setRowSorter(sorter);



       // jTable1.repaint();
        java.net.URL url = ClassLoader.getSystemResource("com/webmarmun/camera.png");
        Toolkit kit = Toolkit.getDefaultToolkit();
        Image img = kit.createImage(url);
        this.setIconImage(img);

        JMenuBar menuBar = new JMenuBar();
        
        // Add the menubar to the frame
        setJMenuBar(menuBar);

        // Define and add two drop down menu to the menubar
        JMenu fileMenu = new JMenu("Додавање поротника");
        JMenu editMenu = new JMenu("Додавање судија");
        JMenu cene = new JMenu("Измена цена");
        JMenu izvestaji = new JMenu("Креирање извештаја");
        JMenu izmenaPorotnika = new JMenu("Измена поротника");
        JMenu izmenaSudije = new JMenu("Измена судије");
        
        
        menuBar.add(fileMenu);
        menuBar.add(izmenaPorotnika);
        menuBar.add(editMenu);
        menuBar.add(izmenaSudije);
        menuBar.add(cene);
        menuBar.add(izvestaji);
        menuBar.add(filterText);
     
       



        fileMenu.addMouseListener(
                new MouseAdapter() {

                    @Override
                    public void mouseClicked(MouseEvent evt) {
                        Porotnik p = new Porotnik();
                        p.setVisible(true);
                    }
                });

        editMenu.addMouseListener(
                new MouseAdapter() {

                    @Override
                    public void mouseClicked(MouseEvent evt) {
                        Sudija s = new Sudija();
                        s.setVisible(true);
                    }
                });

        cene.addMouseListener(
                new MouseAdapter() {

                    @Override
                    public void mouseClicked(MouseEvent evt) {
                        Cene c = new Cene();
                        c.setVisible(true);
                    }
                });

        izvestaji.addMouseListener(
                new MouseAdapter() {

                    @Override
                    public void mouseClicked(MouseEvent evt) {
                        Reports c = new Reports();
                        c.setVisible(true);
                    }
                });

        izmenaPorotnika.addMouseListener(
                new MouseAdapter() {

                    @Override
                    public void mouseClicked(MouseEvent evt) {
                        IzmenaPorotnika ip = new IzmenaPorotnika();
                        ip.setVisible(true);
                    }
                });
        izmenaSudije.addMouseListener(
                new MouseAdapter() {

                    @Override
                    public void mouseClicked(MouseEvent evt) {
                        IzmenaSudije is = new IzmenaSudije();
                        is.setVisible(true);
                    }
                });
//        filterText.getDocument().addDocumentListener(
//                new DocumentListener() {
//                    public void changedUpdate(DocumentEvent e) {
//                        newFilter();
//                    }
//                    public void insertUpdate(DocumentEvent e) {
//                        newFilter();
//                    }
//                    public void removeUpdate(DocumentEvent e) {
//                        newFilter();
//                    }
//                });




        jLabel1.setVisible(false);
        jLabel2.setVisible(false);
        jLabel3.setVisible(false);

        jLabel5.setVisible(false);
        jLabel6.setVisible(false);
        jLabel8.setVisible(false);
        jLabel10.setVisible(false);
        jLabel12.setVisible(false);
        jLabel14.setVisible(false);
        jLabel16.setVisible(false);
        jLabel18.setVisible(false);
        porotnik.setVisible(false);
        sudija.setVisible(false);
        subroj.setVisible(false);
        datum.setVisible(false);
        brojsati.setVisible(false);
        posatu.setVisible(false);
        prevoz.setVisible(false);
        pausalno.setVisible(false);
        napomena.setVisible(false);
        jLabel19.setVisible(false);
      //  jTable1.addMouseListener(
//                new MouseAdapter() {
//
//                    @Override
//                    public void mouseClicked(MouseEvent evt) {
//
//                        int col = jTable1.getSelectedColumn();
//                        int row = jTable1.getSelectedRow();
//                        jLabel1.setVisible(true);
//                        jLabel2.setVisible(true);
//                        jLabel3.setVisible(true);
//
//                        jLabel6.setVisible(true);
//                        jLabel8.setVisible(true);
//                        jLabel10.setVisible(true);
//                        jLabel12.setVisible(true);
//                        jLabel14.setVisible(true);
//                        jLabel16.setVisible(true);
//                        jLabel18.setVisible(true);
//                        porotnik.setVisible(true);
//                        napomena.setVisible(true);
//                        sudija.setVisible(true);
//                        subroj.setVisible(true);
//                        datum.setVisible(true);
//                        brojsati.setVisible(true);
//                        posatu.setVisible(true);
//                        prevoz.setVisible(true);
//                        pausalno.setVisible(true);
//                        jLabel19.setVisible(true);
//                        porotnik.setText(jTable1.getValueAt(row, 2).toString());
//
//                        sudija.setText(jTable1.getValueAt(row, 3).toString());
//                        subroj.setText(jTable1.getValueAt(row, 0).toString());
//                        napomena.setText(jTable1.getValueAt(row, 9).toString());
//                        datum.setText(jTable1.getValueAt(row, 1).toString());
//                        brojsati.setText(jTable1.getValueAt(row, 4).toString());
//                        posatu.setText(jTable1.getValueAt(row, 5).toString());
//                        prevoz.setText(jTable1.getValueAt(row, 6).toString());
//                        pausalno.setText(jTable1.getValueAt(row, 7).toString());
//                        int brojsati = Integer.parseInt(jTable1.getValueAt(row, 4).toString());
//                        Float radnisat = new Float(jTable1.getValueAt(row, 5).toString());
//                        Float prevoz = new Float(jTable1.getValueAt(row, 6).toString());
//                        Float pausalno = new Float(jTable1.getValueAt(row, 7).toString());
//                        Float ukupno = (brojsati * radnisat) + prevoz + pausalno;
//                        jTable1.setValueAt(ukupno, row, 8);
//                        sveZajedno = Float.toString(ukupno);
//                        jLabel19.setText(sveZajedno);
//
//                        SU = subroj.getText();
//                        DATUM = datum.getText();
//                        POROTNIK = porotnik.getText();
//                        SUDIJA = sudija.getText();
//                        MESTO = "Београд";
//                        RADNISAT = radnisat;
//                        BROJSATI = brojsati;
//                        PREVOZ = prevoz;
//                        PAUSALNO = pausalno;
//                        UKUPNO = ukupno;
//                        NAPOMENA = napomena.getText();




//
//                    }
//                });
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        porotniciPUEntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("porotniciPU").createEntityManager();
        evidencijaQuery = java.beans.Beans.isDesignTime() ? null : porotniciPUEntityManager.createQuery("SELECT e FROM Evidencija e");
        evidencijaList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : evidencijaQuery.getResultList();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jInternalFrame1 = new javax.swing.JInternalFrame();
        brojsati = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        pausalno = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        datum = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        porotnik = new javax.swing.JLabel();
        prevoz = new javax.swing.JLabel();
        subroj = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        posatu = new javax.swing.JLabel();
        sudija = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        napomena = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu2 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Први основни суд у Београду - Евиденција поротника");
        setIconImages(null);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jButton1.setText("ШТАМПА ПРВОГ ДЕЛА");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(680, 460, 210, 60));

        jButton2.setBackground(new java.awt.Color(255, 51, 51));
        jButton2.setForeground(new java.awt.Color(255, 255, 255));
        jButton2.setText("ШТАМПА КОНАЧНО");
        jButton2.setMaximumSize(new java.awt.Dimension(145, 23));
        jButton2.setMinimumSize(new java.awt.Dimension(145, 23));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(680, 530, 200, 60));

        jButton3.setBackground(new java.awt.Color(0, 153, 255));
        jButton3.setText("Измена");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 390, 130, 50));

        jButton4.setBackground(new java.awt.Color(102, 255, 153));
        jButton4.setText("Додавање");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(760, 390, 130, 50));

        jInternalFrame1.setBorder(null);
        jInternalFrame1.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        jInternalFrame1.setTitle("Изабрано решење");
        jInternalFrame1.setMaximumSize(new java.awt.Dimension(600, 500));
        jInternalFrame1.setVisible(true);

        brojsati.setText("jLabel11");

        jLabel6.setText("СУ број:");

        jLabel19.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel19.setText("jLabel19");

        jLabel3.setText("Судија:");

        jLabel8.setText("Датум:");

        pausalno.setText("jLabel17");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel5.setText("Изабрано решење:");

        datum.setText("jLabel9");

        jLabel16.setText("Паушално:");

        jLabel14.setText("Превоз:");

        jLabel10.setText("Број сати:");

        jLabel18.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel18.setText("Укупно:");

        jLabel2.setText("Поротник:");

        porotnik.setText("jLabel1");

        prevoz.setText("jLabel15");

        subroj.setText("jLabel7");

        jLabel12.setText("Цена по сату:");

        posatu.setText("jLabel13");

        sudija.setText("jLabel4");

        jLabel1.setText("Напомена:");

        napomena.setText("jLabel7");

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel8)
                        .addGap(81, 81, 81)
                        .addComponent(datum))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addGap(69, 69, 69)
                        .addComponent(brojsati))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(49, 49, 49)
                        .addComponent(posatu))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addGap(80, 80, 80)
                        .addComponent(prevoz))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addGap(65, 65, 65)
                        .addComponent(pausalno))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(64, 64, 64)
                                .addComponent(porotnik))
                            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addGap(78, 78, 78)
                                .addComponent(sudija))
                            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addGap(75, 75, 75)
                                .addComponent(subroj))))
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel18))
                        .addGap(67, 67, 67)
                        .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(napomena)
                            .addComponent(jLabel19))))
                .addContainerGap(229, Short.MAX_VALUE))
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(6, 6, 6)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(porotnik))
                .addGap(5, 5, 5)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(sudija))
                .addGap(6, 6, 6)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(subroj))
                .addGap(6, 6, 6)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(datum))
                .addGap(7, 7, 7)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(brojsati))
                .addGap(6, 6, 6)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(posatu))
                .addGap(6, 6, 6)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel14)
                    .addComponent(prevoz))
                .addGap(6, 6, 6)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jInternalFrame1Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel16))
                    .addComponent(pausalno))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(napomena))
                .addGap(18, 18, 18)
                .addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19)
                    .addComponent(jLabel18))
                .addGap(56, 56, 56))
        );

        jPanel1.add(jInternalFrame1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 390, 410, 330));

        jButton5.setText("Освежи табелу");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 390, -1, 44));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(16, 5, -1, 720));

        jMenu2.setText("Додај поротника");
        jMenuBar2.add(jMenu2);

        jMenu3.setText("Додај судију");
        jMenuBar2.add(jMenu3);

        setJMenuBar(jMenuBar2);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-947)/2, (screenSize.height-819)/2, 947, 819);
    }// </editor-fold>//GEN-END:initComponents
     */
    private void initComponents() {
       // bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

      //  porotniciPUEntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("porotniciPU").createEntityManager();
       // evidencijaQuery = java.beans.Beans.isDesignTime() ? null : porotniciPUEntityManager.createQuery("SELECT e FROM Evidencija e ");
       // evidencijaList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : evidencijaQuery.getResultList();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        table = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jInternalFrame1 = new javax.swing.JInternalFrame();
        brojsati = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        pausalno = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        datum = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        porotnik = new javax.swing.JLabel();
        prevoz = new javax.swing.JLabel();
        subroj = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        posatu = new javax.swing.JLabel();
        sudija = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        napomena = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();
        filterText = new javax.swing.JTextField();
        



        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Први основни суд у Београду - Евиденција поротника");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        table.setRowHeight(25);
      //  jTable1.getTableHeader().setReorderingAllowed(false);

//        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, evidencijaList, jTable1, "updating");
//        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${su}"));
//        columnBinding.setColumnName("Su");
//        columnBinding.setColumnClass(Integer.class);
//        columnBinding.setEditable(false);
//        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${datum}"));
//        columnBinding.setColumnName("Datum");
//        columnBinding.setColumnClass(String.class);
//        columnBinding.setEditable(false);
//        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${imePorotnika}"));
//        columnBinding.setColumnName("Ime Porotnika");
//        columnBinding.setColumnClass(String.class);
//        columnBinding.setEditable(false);
//        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${imeSudije}"));
//        columnBinding.setColumnName("Ime Sudije");
//        columnBinding.setColumnClass(String.class);
//        columnBinding.setEditable(false);
//        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${brojSati}"));
//        columnBinding.setColumnName("Broj Sati");
//        columnBinding.setColumnClass(Integer.class);
//        columnBinding.setEditable(false);
//        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${poSatu}"));
//        columnBinding.setColumnName("Po Satu");
//        columnBinding.setColumnClass(Float.class);
//        columnBinding.setEditable(false);
//        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${prevoz}"));
//        columnBinding.setColumnName("Prevoz");
//        columnBinding.setColumnClass(Float.class);
//        columnBinding.setEditable(false);
//        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${pausalno}"));
//        columnBinding.setColumnName("Pausalno");
//        columnBinding.setColumnClass(Float.class);
//        columnBinding.setEditable(false);
//        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${ukupno}"));
//        columnBinding.setColumnName("Ukupno");
//        columnBinding.setColumnClass(Float.class);
//        columnBinding.setEditable(false);
//        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${napomena}"));
//        columnBinding.setColumnName("Napomena");
//        columnBinding.setColumnClass(String.class);
//        columnBinding.setEditable(false);
//        bindingGroup.addBinding(jTableBinding);
//        jTableBinding.bind();
//        jTable1.getColumnModel().getColumn(2).setPreferredWidth(180);
//        jTable1.getColumnModel().getColumn(3).setPreferredWidth(180);
//        jTable1.getColumnModel().getColumn(4).setPreferredWidth(60);
//        jScrollPane1.setViewportView(jTable1);
         jScrollPane1.setViewportView(table);
        jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 899, 380));

        jButton1.setText("ШТАМПА ПРВОГ ДЕЛА");
        jButton1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(690, 470, 200, 60));

        jButton2.setBackground(new java.awt.Color(255, 51, 51));
        jButton2.setForeground(new java.awt.Color(255, 255, 255));
        jButton2.setText("ШТАМПА КОНАЧНО");
        jButton2.setMaximumSize(new java.awt.Dimension(145, 23));
        jButton2.setMinimumSize(new java.awt.Dimension(145, 23));
        jButton2.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(690, 550, 200, 60));

        jButton3.setBackground(new java.awt.Color(0, 153, 255));
        jButton3.setText("Измена");
        jButton3.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 390, 130, 50));
       
       // jPanel1.add(filterText, new org.netbeans.lib.awtextra.AbsoluteConstraints(610, 460, 150, 30));
        jButton4.setBackground(new java.awt.Color(102, 255, 153));
        jButton4.setText("Додавање");
        jButton4.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(760, 390, 130, 50));

        jInternalFrame1.setBorder(null);
        jInternalFrame1.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        jInternalFrame1.setTitle("Изабрано решење");
        jInternalFrame1.setMaximumSize(new java.awt.Dimension(600, 500));
        jInternalFrame1.setVisible(true);

        brojsati.setText("jLabel11");

        jLabel6.setText("СУ број:");

        jLabel19.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel19.setText("jLabel19");

        jLabel3.setText("Судија:");

        jLabel8.setText("Датум:");

        pausalno.setText("jLabel17");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel5.setText("Изабрано решење:");

        datum.setText("jLabel9");

        jLabel16.setText("Паушално:");

        jLabel14.setText("Превоз:");

        jLabel10.setText("Број сати:");

        jLabel18.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel18.setText("Укупно:");

        jLabel2.setText("Поротник:");

        porotnik.setText("jLabel1");

        prevoz.setText("jLabel15");

        subroj.setText("jLabel7");

        jLabel12.setText("Цена по сату:");

        posatu.setText("jLabel13");

        sudija.setText("jLabel4");

        jLabel1.setText("Напомена:");
       
        filterText.setText("Претрага по датуму");

        napomena.setText("jLabel7");

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
                jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jInternalFrame1Layout.createSequentialGroup().addContainerGap().addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jInternalFrame1Layout.createSequentialGroup().addGap(2, 2, 2).addComponent(jLabel8).addGap(81, 81, 81).addComponent(datum)).addGroup(jInternalFrame1Layout.createSequentialGroup().addComponent(jLabel10).addGap(69, 69, 69).addComponent(brojsati)).addGroup(jInternalFrame1Layout.createSequentialGroup().addComponent(jLabel12).addGap(49, 49, 49).addComponent(posatu)).addGroup(jInternalFrame1Layout.createSequentialGroup().addComponent(jLabel14).addGap(80, 80, 80).addComponent(prevoz)).addGroup(jInternalFrame1Layout.createSequentialGroup().addComponent(jLabel16).addGap(65, 65, 65).addComponent(pausalno)).addGroup(jInternalFrame1Layout.createSequentialGroup().addGap(2, 2, 2).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel5).addGroup(jInternalFrame1Layout.createSequentialGroup().addComponent(jLabel2).addGap(64, 64, 64).addComponent(porotnik)).addGroup(jInternalFrame1Layout.createSequentialGroup().addComponent(jLabel3).addGap(78, 78, 78).addComponent(sudija)).addGroup(jInternalFrame1Layout.createSequentialGroup().addComponent(jLabel6).addGap(75, 75, 75).addComponent(subroj)))).addGroup(jInternalFrame1Layout.createSequentialGroup().addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel1).addComponent(jLabel18)).addGap(67, 67, 67).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(napomena).addComponent(jLabel19)))).addContainerGap(229, Short.MAX_VALUE)));
        jInternalFrame1Layout.setVerticalGroup(
                jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jInternalFrame1Layout.createSequentialGroup().addContainerGap().addComponent(jLabel5).addGap(6, 6, 6).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel2).addComponent(porotnik)).addGap(5, 5, 5).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel3).addComponent(sudija)).addGap(6, 6, 6).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel6).addComponent(subroj)).addGap(6, 6, 6).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel8).addComponent(datum)).addGap(7, 7, 7).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel10).addComponent(brojsati)).addGap(6, 6, 6).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel12).addComponent(posatu)).addGap(6, 6, 6).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel14).addComponent(prevoz)).addGap(6, 6, 6).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jInternalFrame1Layout.createSequentialGroup().addGap(2, 2, 2).addComponent(jLabel16)).addComponent(pausalno)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1).addComponent(napomena)).addGap(18, 18, 18).addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel19).addComponent(jLabel18)).addGap(56, 56, 56)));

        jPanel1.add(jInternalFrame1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 390, 410, 330));

        jButton5.setText("Освежи табелу");
        jButton5.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton5, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 390, -1, 44));


        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(16, 5, -1, -1));




       // bindingGroup.bind();

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width - 947) / 2, (screenSize.height - 775) / 2, 947, 775);
    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed


        BufferedImage bi;
        Font font = new Font("Arial", Font.PLAIN, 25);
        Component frame1 = null;
        try {

            bi = ImageIO.read(new File("zahtev.jpg"));
            Graphics2D g2 = bi.createGraphics();
            g2.setColor(Color.black);
            g2.setFont(font);
            g2.drawString(datum.getText(), 750, 255);
            g2.drawString(porotnik.getText(), 520, 518);
            g2.drawString(datum.getText(), 330, 547);
            g2.drawString(subroj.getText(), 300, 842);
            g2.drawString(datum.getText(), 430, 842);


            File outputfile = new File("prvi_deo_resenja/" + POROTNIK + DATUM + ".jpg");



            ImageIO.write(bi, "jpg", outputfile);
            PrintImage p = new PrintImage();
            try {
                p.print(outputfile.getPath(), 1);
            } catch (Exception ex) {
                Logger.getLogger(FirstFrame.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (IOException ex) {
            Logger.getLogger(FirstFrame.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(frame1,
                    "Грешка код читања документа !\n" + ex.toString(),
                    "Први основни суд у Београду",
                    JOptionPane.WARNING_MESSAGE);
        }




    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        BufferedImage bi;
        Font font = new Font("Arial", Font.PLAIN, 25);
        Component frame1 = null;
        try {

            bi = ImageIO.read(new File("empty.png"));
            Graphics2D g2 = bi.createGraphics();
            g2.setColor(Color.black);
            g2.setFont(font);
            //g2.drawString(datum.getText(), 770, 255);
            //g2.drawString(porotnik.getText(), 520, 518);
            //g2.drawString(datum.getText(), 350, 547);
            //g2.drawString(subroj.getText(), 300, 842);
            //g2.drawString(datum.getText(), 450, 842);
            g2.drawString(porotnik.getText(), 440, 1030);
            g2.drawString("Београд", 950, 1030);
            g2.drawString(datum.getText(), 640, 1060);
            g2.drawString(prevoz.getText(), 830, 1108);
            g2.drawString("0,0", 830, 1143);
            g2.drawString(pausalno.getText(), 830, 1180);
            g2.drawString(posatu.getText(), 830, 1217);
            g2.drawString(sveZajedno, 830, 1255);

            File outputfile = new File("resenja/" + POROTNIK + DATUM + ".jpg");
            ImageIO.write(bi, "jpg", outputfile);
            PrintImage p = new PrintImage();
            try {
                p.print("resenja/" + POROTNIK + DATUM + ".jpg", 1);
            } catch (Exception ex) {
                Logger.getLogger(FirstFrame.class.getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(frame1,
                        "Грешка код штампања документа !\n" + ex.toString(),
                        "Први основни суд у Београду",
                        JOptionPane.WARNING_MESSAGE);
            }

        } catch (IOException ex) {
            Logger.getLogger(FirstFrame.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(frame1,
                    "Грешка код читања документа !\n" + ex.toString(),
                    "Први основни суд у Београду",
                    JOptionPane.WARNING_MESSAGE);
        }


    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        Component frame2 = null;
        if (subroj.isShowing()) {
            Izmena i = new Izmena();
            i.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(frame2,
                    "Морате изабрати неко од решења за измену !",
                    "Први основни суд у Београду",
                    JOptionPane.WARNING_MESSAGE);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
//        try {
//            java.util.List<com.webmarmun.Evidencija> data = evidencijaQuery.getResultList();
//
//            Binding b = findBinding(this.evidencijaList, this.jTable1);
//            // Unbind previous
//            b.unbind();
//
//            // Clear our own Query Result List
//            this.evidencijaList.clear();
//            for (Object entity : data) {
//                porotniciPUEntityManager.refresh(entity);
//            }
//            // Add data to this Query Result List
//            this.evidencijaList.addAll(data);
//
//            // Bind it
//            b.bind();
//        } catch (NoResultException e) {
//            System.out.println(e.getMessage());
//        } catch (Exception e) {
//            System.out.println(e.getMessage());
//        }

        // Repaint our JTable
//        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(jTable1.getModel());
//        jTable1.setRowSorter(sorter);
       // this.jTable1.repaint();
//        porotniciPUEntityManager.getTransaction().begin();
//        java.util.Collection data = evidencijaQuery.getResultList();
//        for (Object entity : data) {
//            porotniciPUEntityManager.refresh(entity);
//        }
//        evidencijaList.clear();
//        evidencijaList.addAll(data);
//        jTable1.updateUI();
//        FirstFrame f=new FirstFrame();
//       this.dispose();
//       f.setVisible(true);
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        Dodavanje d = new Dodavanje();
        d.setVisible(true);
    }//GEN-LAST:event_jButton4ActionPerformed
    /**/

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FirstFrame().setVisible(true);
            }
        });
    }
    /*
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel brojsati;
    private javax.swing.JLabel datum;
    private java.util.List<com.webmarmun.Evidencija> evidencijaList;
    private javax.persistence.Query evidencijaQuery;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    public javax.swing.JButton jButton5;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel napomena;
    private javax.swing.JLabel pausalno;
    private javax.persistence.EntityManager porotniciPUEntityManager;
    private javax.swing.JLabel porotnik;
    private javax.swing.JLabel posatu;
    private javax.swing.JLabel prevoz;
    public javax.swing.JLabel subroj;
    private javax.swing.JLabel sudija;
    // End of variables declaration//GEN-END:variables
     */
    private javax.swing.JLabel brojsati;
    private javax.swing.JLabel datum;
    private java.util.List<com.webmarmun.Evidencija> evidencijaList;
    private javax.persistence.Query evidencijaQuery;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    public javax.swing.JButton jButton5;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable table;
    private javax.swing.JLabel napomena;
    private javax.swing.JLabel pausalno;
    private javax.persistence.EntityManager porotniciPUEntityManager;
    private javax.swing.JLabel porotnik;
    private javax.swing.JLabel posatu;
    private javax.swing.JLabel prevoz;
    public javax.swing.JLabel subroj;
    private javax.swing.JLabel sudija;
    private javax.swing.JTextField filterText;
 
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;

    // End of variables declaration
    public class PrintImage {

        public void print(String s, int i) throws Exception {
            Component frame = null;
            try {
                PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
                pras.add(MediaSize.findMedia(10, 10, Size2DSyntax.MM));
                pras.add(new Copies(i));

                PrintService pss[] = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.JPEG, pras);

                if (pss.length == 0) {
                    // throw new RuntimeException("Штампач није пронађен.");
                    JOptionPane.showMessageDialog(frame,
                            "Штампач није пронађен !",
                            "Први основни суд у Београду",
                            JOptionPane.WARNING_MESSAGE);
                }

                PrintService ps = pss[0];


                DocPrintJob job = ps.createPrintJob();

                FileInputStream fin = new FileInputStream(s);
                Doc doc = new SimpleDoc(fin, DocFlavor.INPUT_STREAM.JPEG, null);

                job.print(doc, pras);

                fin.close();
            } catch (IOException ie) {
                JOptionPane.showMessageDialog(frame,
                        "Грешка код штампања !/n" + ie.toString(),
                        "Први основни суд у Београду",
                        JOptionPane.WARNING_MESSAGE);
            } catch (PrintException pe) {
                JOptionPane.showMessageDialog(frame,
                        "Грешка код штампања !/n" + pe.toString(),
                        "Први основни суд у Београду",
                        JOptionPane.WARNING_MESSAGE);
            }
        }
    }

    public final Binding findBinding(Object source, Object target) {
        for (Iterator<Binding> i = this.bindingGroup.getBindings().iterator(); i.hasNext();) {
            Binding b = i.next();
            boolean found = (source == null || b.getSourceObject() == source)
                    && (target == null || b.getTargetObject() == target);
            if (found) {
                return b;
            }
        }
        return null;
    }

//    private void newFilter() {
//        RowFilter<MyTableModel, Object> rf = null;
//        //If current expression doesn't parse, don't update.
//        try {
//
//            rf = RowFilter.regexFilter(filterText.getText(), 0);
//        } catch (java.util.regex.PatternSyntaxException e) {
//            return;
//        }
//        sorter.setRowFilter(rf);
//    }

//    class MyTableModel extends AbstractTableModel {
//
//        public int getColumnCount() {
//            return jTable1.getModel().getColumnCount();
//        }
//
//        public int getRowCount() {
//            return jTable1.getModel().getRowCount();
//        }
//
//        @Override
//        public String getColumnName(int col) {
//            return jTable1.getColumnName(1);
//        }
//
//        public Object getValueAt(int row, int col) {
//            return jTable1.getModel().getValueAt(row, 1);
//        }
//    }

    private void showTable(){
     String serverName = "localhost";
     String mydatabase = "porotnici";
     String url = "jdbc:mysql://" + serverName + "/" + mydatabase + "?useUnicode=true&characterEncoding=utf8";
     String username = "root";
     String password = "";
        Vector columnNames = new Vector();
        Vector data = new Vector();
        JTable jtable2=new JTable();
        DefaultTableModel m = new DefaultTableModel();
        float rs;
        float prev;
        float pau;
        int su;
        String datum2;
        String imePorotnika;
        int BrojSati;
         try {

            java.sql.Connection connection = null;
            connection = DriverManager.getConnection(url, username, password);

            java.sql.PreparedStatement t = connection.prepareStatement("SELECT * from evidencija");
            ResultSet trs = null;
            trs = t.executeQuery();
            java.sql.ResultSetMetaData md = trs.getMetaData();
            int columns = md.getColumnCount();
            //  Get column names

            for (int i = 1; i <= columns; i++)
            {
                columnNames.addElement( md.getColumnName(i) );
            }
            while (trs.next()) {
                Vector row = new Vector(columns);

                for (int i = 1; i <= columns; i++)
                {
                    row.addElement( trs.getObject(i) );
                }

                data.addElement( row );
//                su = trs.getInt("id");
//                datum2 = trs.getString("datum");
//                imePorotnika = trs.getString("datum");
//                BrojSati = trs.getInt("broj_sati");
//                rs = trs.getFloat("po_satu");
//                prev = trs.getFloat("prevoz");
//                pau = trs.getFloat("pausalno");
             }

            trs.close();
            connection.close();

            JTable table = new JTable(data, columnNames)
        {
                @Override
            public Class getColumnClass(int column)
            {
                for (int row = 0; row < getRowCount(); row++)
                {
                    Object o = getValueAt(row, column);

                    if (o != null)
                    {
                        return o.getClass();
                    }
                }

                return Object.class;
            }
        };
        JScrollPane scrollPane = new JScrollPane( table );
        getContentPane().add( scrollPane );

        JPanel buttonPanel = new JPanel();
        getContentPane().add( buttonPanel, BorderLayout.SOUTH );
            }catch(SQLException e){
               System.out.println(e.toString());
            }

    }
}
